package com.weijin.bookborrowmanagesystem.service.impl;

import com.weijin.bookborrowmanagesystem.common.Result;
import com.weijin.bookborrowmanagesystem.enums.BookEnum;
import com.weijin.bookborrowmanagesystem.enums.ExceptionEnum;
import com.weijin.bookborrowmanagesystem.exception.AppException;
import com.weijin.bookborrowmanagesystem.mapper.BookMapper;
import com.weijin.bookborrowmanagesystem.pojo.Book;
import com.weijin.bookborrowmanagesystem.service.BookService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Objects;

/**
 * @Author WeiJin
 * @Version 1.0
 * @Date 2025/3/13 10:21
 */
@Service
public class BookServiceImpl implements BookService {
    @Resource
    BookMapper bookMapper;

    @Override
    public Result<String> addBook(Book book) {
        int insert = bookMapper.insert(book);
        return insert > 0 ? Result.success("添加成功") : Result.failed("添加失败");
    }

    @Override
    public Result<List<Book>> queryAll() {
        List<Book> books = bookMapper.selectAll();
        return Result.success("查询成功", books);
    }

}
